home *** CD-ROM | disk | FTP | other *** search
- program Project1;
-
- {$IFDEF Win32}
- {$APPTYPE CONSOLE}
- {$ENDIF}
-
- uses
- SysUtils,
- {$IFDEF Windows}
- WinCrt,
- {$ENDIF}
- AAExpr in 'AAExpr.pas',
- AAStStk in 'AAStStk.pas',
- AAChStk in 'AAChStk.pas',
- AAVarLst in 'AAVarLst.pas';
-
- var
- (*****
- MyStack : TaaStringStack;
- i : longint;
- S : string[15];
- Expected: longint;
- Value : longint;
- ec : integer;
- *****)
- MyExpr : TaaExpressionParser;
- Expr : string;
- Variable: string;
- DValue : double;
- begin
- writeln('Starting test...');
- try
- write('Enter an expression: ');
- readln(Expr);
- while (Expr <> '') do begin
- MyExpr := TaaExpressionParser.Create(Expr);
- try
- {MyExpr.TokenPrint;}
- write('Enter a variable: ');
- readln(Variable);
- while (Variable <> '') do begin
- write('Enter a value: ');
- readln(DValue);
- MyExpr.Variable[Variable] := DValue;
- write('Enter a variable: ');
- readln(Variable);
- end;
- writeln(MyExpr.RPNExpression);
- writeln(MyExpr.Value:20:9);
- except
- on E:Exception do begin
- writeln(E.Message);
- MyExpr.Free;
- end;
- end;
- write('Enter an expression: ');
- readln(Expr);
- end;
-
- (****** code to test TaaStringStack...
- MyStack := TaaStringStack.Create(4096);
- try
- for i := 1 to 200000 do begin
- MyStack.Push(IntToStr(i));
- end;
- writeln('Count: ', MyStack.Count);
- writeln('Chunks: ', MyStack.ChunkCount);
- writeln('Slack: ', MyStack.SlackSpace);
- readln;
- Expected := 200000;
- for i := 1 to 200000 do begin
- S := MyStack.Pop;
- Val(S, Value, ec);
- if (ec <> 0) or (Value <> Expected) then
- raise Exception.create('Invalid value popped from stack');
- dec(Expected);
- end;
- writeln('Count: ', MyStack.Count);
- writeln('Chunks: ', MyStack.ChunkCount);
- writeln('Slack: ', MyStack.SlackSpace);
- readln;
- finally
- MyStack.Free;
- end;
- ****)
-
- except
- on E: Exception do
- writeln(E.Message);
- end;
- writeln('Done');
- readln;
- end.
-